from haystack import indexes

from goods.models import SKU


class SKUIndex(indexes.SearchIndex, indexes.Indexable):

    """
        索引类
    """

    # 指定索引字段
    text = indexes.CharField(document=True, use_template=True)

    def get_model(self):
        # 指定模型类数据建立索引
        return SKU

    def index_queryset(self, using=None):
        # 过索引的数据信息
        return self.get_model().objects.filter(is_launched=True)

